<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>comic</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link type="text/css" rel="stylesheet" href="../../css/pepper-grinder/jquery-ui-1.8.16.custom.css" />
	<link type="text/css" rel="stylesheet" href="css/comic.css" />
	<link type="text/css" rel="stylesheet" href="../../css/jRating.jquery.css" />
	<link type="text/css" rel="stylesheet" href="../../css/popeWin.css" />
	<script type="text/javascript" src="../../js/jquery.min.js"></script>
	<script type="text/javascript" src="../../js/jquery-ui-1.8.16.custom.min.js"></script>
	<script type="text/javascript" src="../../js/jquery.mousewheel.min.js"></script>
	<script type="text/javascript" src="../../js/popeScroll.js"></script>
	<script type="text/javascript" src="../../js/popeWin.js"></script>
	<script type="text/javascript" src="../../js/jRating.jquery.js"></script>
	<script language="JavaScript" type="text/JavaScript">
		var hidetr = 0;
		var name;
		var author;
		var comicid;
		$(document).ready(function() {
			var cururl = window.location.href;
			comicid = cururl.split('=')[1];
			
			$(window).resize(function() {
				refresh();
			});
			refresh();
			
			$("#toolcontent").hover(function(){
				$(this).removeClass("transparent_0");
				$(this).addClass("transparent_class");
			},function(){
				$(this).removeClass("transparent_class");
				$(this).addClass("transparent_0");
			});


			$.getJSON("comic_getComicToJsonById.do",{comicId:comicid},function(json){
				
				$.get("rating_getRatingAVG.do",{objid:comicid},function(data){
					var ratingnum = parseInt(data);
					
					var divstr = '<div style="width:100%;float:left;">'+
							'<div class="imgdiv" style="padding-left:20px;padding-top:20px;float:left;">'+
								'<img onclick="showComic(this)" id="'+json.id+'" src="'+json.pageurl+'" style="width:100%;height:100%;cursor:pointer;border:#f8f7f0 2px solid;"/>'+
							'</div>'+
							'<div  style="float:left;padding-left:20px;padding-top:15px;" >'+
								'<div style="padding-top:5px;height:25px;line-height:23px;">'+
									'<div style="float:left;">'+json.name+'</div>'+
									'<div id="'+ratingnum+'_'+comicid+'" class="rating"  style="width:100%;float:left;"></div>'+
									'<div style="float:left;">&nbsp;'+data+'&nbsp;</div>'+
									'<div style="float:left;"><img id="comment_img" onclick="showComment(\''+comicid+'\');" src="../../image/icon2/ichat.png" title="评论" style="width:23px;height:23px;cursor:pointer;" /></div>'+
								'</div>'+
								'<div style="padding-top:5px;">'+"更新至："+json.state+'</div>'+
								'<div style="padding-top:5px;">'+"作者："+json.author+'</div>'+
								'<div id="content" style="padding-top:5px;width:500px;">'+"简介："+json.content+'</div>'+
							'</div>'+
						'</div>';
					$("#info").append(divstr);
					refresh();
					name = json.name;
					author = json.author;
					
					$.getJSON("rating_getUserRating.do",{objid:comicid},function(json){
						
						if(json == null){
							$(".rating").jRating({
								bigStarsPath : "../../image/rating/stars.png" 
							});
						}else{
							$(".rating").jRating({
								bigStarsPath : "../../image/rating/stars.png",
								isDisabled:true
							});
						}
					});
					
					
				});
				

			});
			$.getJSON("comic_getComicChaptersListToJsonByComicId.do",{comicId:comicid},function(json){
				var htmlstr = "";
				for(var i=0;i<json.length;i++){
					var tdstr = "<td><a id='"+json[i].id+"' href='#' onclick='showPage(this);'>"+json[i].name+"</a></td>";
					if(i%7==0){
						
						htmlstr = htmlstr + "<tr id='tr"+i/7+"'>" + tdstr;
					}else if(i%7==6){
						htmlstr = htmlstr +  tdstr + "</tr>";
					}else{
						htmlstr = htmlstr + tdstr;
					}
					
					
				}	
				$("#chapters").append(htmlstr);
				refresh();
				
			});

			$("#chapters").popeScroll({
				offset_top:-300,
				top:45
			});
			
			

		});

		function refresh(){
			var winheight = $(window).height();
			var winwidth = $(window).width();
			$("#bodydiv").css("height",winheight);
			$("#list").css("height",winheight*0.6);
			$("#content").css("width",winwidth*0.75);
			$(".imgdiv").css("width",winheight*0.15);
			$(".imgdiv").css("height",winheight*0.20);
			$("td").css("width",winwidth/7)
			
			
		}

		function showPage(obj){
			var chapters = $(obj).text();
			var winheight = $(window.parent).height();
			var winwidth = $(window.parent).width();
			$.getJSON("comic_getComicPagesListToJsonByComicChaptersId.do",{comicChaptersId:obj.id},function(json){
					if(json.length == 0){
						alert("该章节未收录");
						return;
					}
					var div = '<div id="modal" ><div id="galleria" style="width:100%;height:90%;">';
					for(var i=0;i<json.length;i++){
						div = div + '<a href="'+json[i].url+'" /><img title="'+name+'" alt="'+chapters+'" src="'+json[i].url+'" /></a>';
					}

					div = div + "</div></div>";

					var $modal = $(div).attr('id', 'modal').css({
						
						zIndex: 9999,
						padding: '10px',
						width: winwidth*0.55,
						height: winheight,
						margin: '0 auto',
						opacity: 0.8,
						position: 'absolute',
						top: '5%',
						left: '22%'
					});
					window.parent.showOverlay($modal);
					//window.parent.showGalleria();
			});

			
			
		}

		function goback(){
			window.parent.resizeWin("comic1",0.5,0.8);
			window.location.href = "main.html";
		}

		function showComment(objid){
			var winheight = $(window).height();
			var winwidth = $(window).width();
			
			var showstate = $("#miniWin_comment_img").css("display");
			if(showstate==null||showstate=="none"){
				$.popeWinMini({
					id:"comment_img",
					width:winwidth*0.5,
					height:winheight*0.8,
					url:"../comment/main.html?id="+comicid
				});
			}else{
				$.popeWinMiniClose({
					id:"comment_img"
				});
			}
		}
		

		
	</script>
</head>
<body style="background-color=transparent;width:100%;margin-left:0px;margin-top:0px;">
	<div id="bodydiv" style="background:url(../../image/bg/5.png)">
		<div id="info" style="width:100%;float:left;"></div>
		<div style="width:100%;height:15px;border-bottom:#f8f7f0 2px solid;float:left;"></div>
		<div  style="width:100%;float:left;">
			<div style="width:100%;float:left;padding-left:20px;padding-top:20px;">章节列表(可以使用鼠标滚轮上下滚动列表)</div>
			<div id="list" style="width:90%;float:left;padding-left:20px;padding-top:20px;overflow:hidden;">
				<table id="chapters"></table>
			</div>
		</div>
		<div id="toolcontent" class="toolcontent transparent_0">
			
			<div style="height:100%;">
				<img title="返回" src="../../image/cover/system/white/MB_0006_back.png" style="width:60px;height:60px;cursor:pointer;float:right;padding-right:10px;" onclick="goback();" /> 
				
				
				
			</div>
		</div>
	</div>
	
		
	
	
	
</body>
</html>